#ifndef __LIBCOMMON_CRADIX_HEAP_H__
#define __LIBCOMMON_CRADIX_HEAP_H__

#include <global/header/types.h>

/* CRADIX HEAP - The critial data structure for implement the timer mechanism */

#define CRH_KEY_BITSIZE         (32)
#define CRH_RADIX_BITSIZE_SHIFT (2)
#define CRH_RADIX_BITSIZE       (1 << CRH_RADIX_BITSIZE_SHIFT)
#define CRH_SEG_COUNT           (8)

typedef uint32_t crh_key_t;

typedef struct crh_node_s
{
	 crh_key_t          key;
	 struct crh_node_s *next, *prev;
} crh_node_t;

#define CRH_SIZE 552
typedef struct crh_s crh_t;

void        crh_init(crh_t *crh);
crh_node_t *crh_set_base(crh_t *crh, crh_key_t base);
crh_key_t   crh_max_step(crh_t *crh);
int         crh_insert(crh_t *crh, crh_node_t *node);
void        crh_remove(crh_t *crh, crh_node_t *node);

#endif
